﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="qlnewstypelang.ascx.cs" Inherits="admin_qlnewstypelang" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<style type="text/css">
    .style1
    {
        width: 112px;
    }
</style>
<center>
<table >
    <tr>
        <td align="left" class="style1">&nbsp;</td>
        <td >
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style1">Loại tin tức: </td>
        <td>
            <asp:DropDownList ID="ddlID" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource2" DataTextField="description" DataValueField="id" 
                Height="31px" Width="230px" ValidationGroup="insert">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="select * from NewsType WHERE id NOT IN (select id from [NewsType_lang] WHERE lang = @lang) ORDER BY [description] DESC">
                <SelectParameters>
                    <asp:ControlParameter ControlID="ddlLang" DefaultValue="vn" Name="lang" />
                </SelectParameters>
            </asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="ddlID" ErrorMessage="*" ValidationGroup="insert">Chưa Chọn Loại tin tức</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Ngôn ngữ: </td>
        <td>
            <asp:DropDownList ID="ddlLang" runat="server" AutoPostBack="True" 
                DataSourceID="SqlDataSource3" DataTextField="lang" DataValueField="id" 
                Height="30px" Width="156px" ValidationGroup="insert">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
                SelectCommand="SELECT [id], [lang] FROM [Languages] ORDER BY [lang] DESC">
            </asp:SqlDataSource>
            </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="ddlLang" ErrorMessage="*" ValidationGroup="insert">Chưa Chọn Ngôn ngữ</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Menu: </td>
        <td>
            <asp:TextBox ID="menu" runat="server" ValidationGroup="insert"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                ControlToValidate="menu" ErrorMessage="*" ValidationGroup="insert">Chưa nhập menu</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="style1">Tiêu đề: </td>
        <td>
            <asp:TextBox ID="title" runat="server" Height="134px" Rows="5" 
                TextMode="MultiLine" Width="350px" ValidationGroup="insert"></asp:TextBox>
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                ControlToValidate="title" ErrorMessage="*" ValidationGroup="insert">Chưa Nhập Tiêu Đề</asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td colspan="2"><center>
            <asp:Button runat="server" ID="addbt" Text="Thêm" 
                onclick="addbt_Click" ValidationGroup="insert"/></center></td>
        <td>&nbsp;</td>
    </tr>
</table>
<br />
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" AllowSorting="True"
        CellPadding="4" ForeColor="#333333" GridLines="None"
        PageSize="5" Width="100%" onrowcreated="GridView1_RowCreated" 
        onrowediting="GridView1_RowEditing" 
    onrowcommand="GridView1_RowCommand" 
    DataSourceID="SqlDataSource1" DataKeyNames="id,lang" 
    onrowdeleting="GridView1_RowDeleting">
        <RowStyle BackColor="#EFF3FB" VerticalAlign="Middle" />
        <EmptyDataRowStyle VerticalAlign="Middle" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#459300" HorizontalAlign="Center" />
        <EmptyDataTemplate>
             <asp:Label ID="Label3" runat="server" Text="Chưa có dữ liệu"></asp:Label>
        </EmptyDataTemplate>
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#57A000" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="ID" SortExpression="id" ItemStyle-HorizontalAlign="Center">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:TemplateField>
            <asp:BoundField DataField="lang" HeaderText="Ngôn ngữ" 
                SortExpression="lang" ItemStyle-HorizontalAlign="Center" ReadOnly="True" >
<ItemStyle HorizontalAlign="Center"></ItemStyle>
            </asp:BoundField>
            <asp:TemplateField HeaderText="Menu" SortExpression="menu">
                <EditItemTemplate>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBox1"
                        ErrorMessage="*" >Chưa nhập menu</asp:RequiredFieldValidator>
                    <br />
                    <asp:TextBox ID="TextBox1" runat="server" Height="23px" 
                        Text='<%# Bind("menu") %>' Width="224px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("menu") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu đề" SortExpression="title">
                <EditItemTemplate>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                        ErrorMessage="*" ControlToValidate="TextBox2">Chưa Nhập Tiêu Đề</asp:RequiredFieldValidator>
                    <br />
                    <asp:TextBox ID="TextBox2" runat="server" Height="48px" Rows="2" 
                        Text='<%# Bind("title") %>' TextMode="MultiLine"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("title") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:CommandField ButtonType="Button" EditText="Sửa" ShowEditButton="True" />
            <asp:CommandField ButtonType="Button" DeleteText="Xoá" 
                ShowDeleteButton="True" />
        </Columns>
        <EditRowStyle BackColor="#003366" VerticalAlign="Middle" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:canhbuomxanhconnectionstring %>" 
    SelectCommand="SELECT * FROM [NewsType_lang] ORDER BY [id] DESC"
    InsertCommand="INSERT INTO [NewsType_lang] ([id], [lang], [menu], [title]) VALUES (@id, @lang, @menu, @title)" 
    DeleteCommand="DELETE FROM [NewsType_lang] WHERE [id] = @id AND [lang] = @lang" 
    UpdateCommand="UPDATE [NewsType_lang] SET [menu] = @menu, [title] = @title WHERE [id] = @id AND [lang] = @lang"
    >
    <DeleteParameters>
            <asp:Parameter Name="id" Type="Int64" />
            <asp:Parameter Name="lang" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="menu" Type="String" />
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="id" Type="Int64" />
            <asp:Parameter Name="lang" Type="String" />
        </UpdateParameters>
    <InsertParameters>
            <asp:ControlParameter ControlID="ddlID" Name="id" PropertyName="SelectedValue" 
                Type="Int64" />
            <asp:ControlParameter ControlID="ddlLang" Name="lang" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="menu" Name="menu" PropertyName="Text" 
                Type="String" />
            <asp:ControlParameter ControlID="title" Name="title" PropertyName="Text" 
                Type="String" />
        </InsertParameters>
</asp:SqlDataSource>
</div>
</center>
